package com.ftg.learn.chapter02.ee.util.vo;

import lombok.Data;

import java.util.List;

/**
 * 分页的通用vo  -
 *
 * @author kangjx
 * @version 1.0
 * @date 2024/1/3 上午9:34
 */
public class PageVo<T> {

    /**
     * 页码
     */
    private Long pageNum;

    /**
     * 每页显示的条数
     */
    private Long pageSize;

    /**
     * 总条数
     */
    private Long total;

    /**
     * 总页数
     */
    private Long pages;

    /**
     * 数据
     */
    private List<T> rows;


    public Long getPageNum() {
        return pageNum;
    }

    public void setPageNum(Long pageNum) {
        this.pageNum = pageNum;
    }

    public Long getPageSize() {
        return pageSize;
    }

    public void setPageSize(Long pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Long getPages() {
        return this.getTotal() % this.pageSize > 0 ? this.getTotal() / this.pageSize + 1 : this.getTotal() / this.pageSize;
    }

    public void setPages(Long pages) {
        this.pages = pages;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    @Override
    public String toString() {
        return "PageVo{" +
                "pageNum=" + pageNum +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", pages=" + this.getPages() +
                ", rows=" + rows +
                '}';
    }
}
